package com.hotelvip.service.batch.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hotelvip.dao.RegionMapper;
import com.hotelvip.entity.Region;
import com.hotelvip.service.batch.RegionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = RuntimeException.class)
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {



    /**
     * 通过父类id查询所有子类
     * @param parentId 父类id
     * @return
     */
    @Override
    public List<Region> findRegionByParentId(Integer parentId) {
        QueryWrapper<Region> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(Region::getParentId,parentId);
        List<Region> regionList = list(wrapper);
        return regionList;
    }

    /**
     * 根据id查询对应地区
     * @param id 区域id
     * @return
     */
    @Override
    public Region findRegionId(Integer id) {

        Region region = getById(id);
        return region;

    }




}
